<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>学员详情查看</title>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet"/>
    <script th:src="@{/layui/layui.js}"></script>
    <script th:src="@{/jquery-3.3.1/jquery-3.3.1.js}"></script>
</head>

<body>
   <form class="layui-form"  th:action="@{/edit}" th:object="${student}" id="studentFrom"  method="post">
       <input type="hidden" name="sid" id="sid" th:value="*{sid}" />
        <div class="layui-form-item" style="margin-top: 20px;">
            <label class="layui-form-label">姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name"  th:value="*{name}" style="width: 400px;" placeholder="请输入姓名"  class="layui-input" >
            </div>
        </div>
       <div class="layui-form-item">
           <label class="layui-form-label">QQ：</label>
           <div class="layui-input-block">
               <input type="text" name="qq" id="qq"  th:value="*{qq}" style="width: 400px;" placeholder="请输入QQ"  class="layui-input" >
           </div>
       </div>

       <div class="layui-form-item">
           <div class="layui-input-block">
               <button type="button" class="layui-btn"  th:onclick="'javascript:save()'">确认</button>
               <button type="reset" class="layui-btn layui-btn-primary">重置</button>
           </div>
       </div>
    </form>

</body>

<script>

    function save(){
       var name = $("#name").val();
       var sid = $("#sid").val();
        var qq = $("#qq").val();
        $.ajax({
            url: "/stu/studentUpdate",
            type: "POST",
            data:{"sid":sid,"name":name,"qq":qq},
            dataType: "json",
            success: function(data){
                if(data==1){
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);  // 关闭layer
                    parent.layer.msg("修改成功", {icon: 6});
                    parent.location.reload();
                }else{
                    parent.layer.msg("修改失败", {icon: 5});
                }
            }
        });
    }

</script>
</html>